package com.example.littleSpider.myapplication.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.example.littleSpider.myapplication.R;
import com.example.littleSpider.myapplication.base.BaseActivity;
import com.example.littleSpider.myapplication.fragment.gankuai.mysend.MysendAllFragment;
import com.example.littleSpider.myapplication.fragment.gankuai.mysend.MysendCompletedFragment;
import com.example.littleSpider.myapplication.fragment.gankuai.mysend.MysendPendingConfirmedFragment;
import com.example.littleSpider.myapplication.fragment.gankuai.mysend.MysendPendingOrderFragment;
import com.example.littleSpider.myapplication.fragment.gankuai.mysend.MysenddispatchFragment;
import com.example.littleSpider.myapplication.myInterfaces.MethodInTitle;
import com.example.littleSpider.myapplication.view.TitleView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by EDZ on 2017/12/14.
 * <p>
 * 赶快-个人中心 我的发单界面
 */

public class MySendActivity extends BaseActivity implements MethodInTitle {


    @BindView(R.id.title_view)
    TitleView title_view;
    @BindView(R.id.mysend_tabs)
    TabLayout mysend_tabs;
    @BindView(R.id.mysend_vp)
    ViewPager mysend_vp;

    FragmentManager manager;
    List<Fragment> fragmentList = new ArrayList<>();
    //我的发单各条目
    MysendAllFragment mysendAllFragment  = new MysendAllFragment();
    MysendPendingConfirmedFragment mysendPendingConfirmedFragment = new MysendPendingConfirmedFragment();
    MysendPendingOrderFragment mysendPendingOrderFragment = new MysendPendingOrderFragment();
    MysenddispatchFragment mysenddispatchFragment = new MysenddispatchFragment();
    MysendCompletedFragment mysendCompletedFragment = new MysendCompletedFragment();

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_mysend;
    }

    @Override
    protected void initView() {

        title_view.initMyTitle("赶快-我的发单", this,false);
        title_view.hideTitleTextImage();

        fragmentList.add(mysendAllFragment);
        fragmentList.add(mysendPendingConfirmedFragment);
        fragmentList.add(mysendPendingOrderFragment);
        fragmentList.add(mysenddispatchFragment);
        fragmentList.add(mysendCompletedFragment);

        manager = getSupportFragmentManager();

        mysend_tabs.setupWithViewPager(mysend_vp);
        mysend_vp.setAdapter(new MyPageAdapter(manager));


    }


    class MyPageAdapter extends FragmentPagerAdapter {

        FragmentManager manager;

        public MyPageAdapter(FragmentManager fm) {
            super(fm);
            manager = fm;
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            if (position == 0){
                return "全部";
            }
            if (position == 1){
                return "待确认";
            }
            if (position == 2){
                return "待接单";
            }
            if (position == 3){
                return "派送中";
            }
            if (position == 4){
                return "已完成";
            }
            return null;
        }

    }


    @Override
    protected void initData() {

    }

    @Override
    public void setGoBack() {
        finish();
    }

    @Override
    public void onRightOne() {

    }

    @Override
    public void onRightTwo() {

    }

    @Override
    public void onTitleText() {

    }
}
